/*package matching;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import control.ProcessedInput;
import control.ProcessedOutput;

public class SE {
	final String sentenceInputPath = "database\\iSentence.txt";
	final String sentenceOutputPath = "database\\oSentence.txt";
	final String keywordsInputPath = "database\\iKey.txt";
	final String keywordsOutputPath = "database\\oKey.txt";

	public ProcessedOutput getAnswers(ProcessedInput keys) throws IOException {

		ProcessedOutput answer = new ProcessedOutput();
		String response = "";

		// input
		boolean isQuestion = false;
		List<String> keyList;
		String keywordResponse = "";

		// learn
		if (keys.isLearning()) {
//			appendKeywords(null, null);
			
			System.out.println("Saving");
			response = "Thank you, Can you tell me more?";
			answer.setExist(true);
			answer.setResponse(response);
			return answer;
		} else {
			// match input
			response = matchSentences(keys.getInput(), sentenceInputPath,
					sentenceOutputPath);
			if (!response.equals("")) {
				answer.setExist(true);
				answer.setResponse(response);
				return answer;
			}

			// get questionWord
			if (!keys.getQuestionWord().isEmpty()) {
				isQuestion = true;
			}

			// match keywords
			keyList = keys.getListKeyword();

			for (String s : keyList) {
				keywordResponse = matchSentences(s, keywordsInputPath,
						keywordsOutputPath);
				if (!keywordResponse.equals("")) {
					if (isQuestion) {
						response = "I think you said about it before. You said that "
								+ keywordResponse;
					} else {
						response = "Oh, you said about "
								+ s
								+ ", didn't you ?\n And now except '"
								+ keywordResponse
								+ "' that you said before, I can know more about you";
					}
					answer.setExist(true);
					answer.setResponse(response);
					return answer;
				}
			}

			// we must learn
			answer.setExist(false);
			if (isQuestion) {
				response = "I don't know about it. Can you explain it to me ?";
			} else {
				response = "Can you tell me about " + keyList.get(0);
			}
			answer.setResponse(response);
			return answer;
		}

	}

	private String matchSentences(String input, String InputPath,
			String OutputPath) throws IOException {
		@SuppressWarnings("resource")
		BufferedReader readerInput = new BufferedReader(new FileReader(
				InputPath));
		String lineInput = "";
		@SuppressWarnings("resource")
		BufferedReader readerResponse = new BufferedReader(new FileReader(
				OutputPath));
		String lineResponse = "";
		while (((lineInput = readerInput.readLine()) != null)
				&& ((lineResponse = readerResponse.readLine()) != null)) {
			if (lineInput.compareTo(input) == 0)
				return lineResponse;
		}
		return "";
	}

	private void appendKeywords(String spec, String path) {
		FileWriter fw = null;
		PrintWriter pw = null;
		try {
			fw = new FileWriter(path, true);
			pw = new PrintWriter(fw);
			pw.write("\n");
			pw.write(spec);
			pw.close();
			fw.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	// singleton
	private static SE instance = null;

	protected SE() {

	}

	public static SE getInstance() {
		if (null == instance) {
			instance = new SE();
		}
		return instance;
	}
}
*/